#ifndef DBBUSQMLAPP_H
#define DBBUSQMLAPP_H

#include <QObject>
#include "../../DbusInterfaces/dbusapp.h"
#include <QDesktopWidget>
#include <QtDeclarative/QDeclarativeView>
#include <QRect>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include "qmlwindow.h"
#include "videowidget.h"

class DbbusQmlApp : public DbusApp
{
    Q_OBJECT
    Q_PROPERTY(bool videoBackground READ isModeComposite  WRITE videoBackground NOTIFY compositeChanged)

public:
    explicit DbbusQmlApp(QString qmlfile, QString appName, QObject *parent = 0);
    Q_INVOKABLE virtual void requestMedia(QString reqkey, QString askerApp, QString reqName, QString reqParam) ;
    Q_INVOKABLE virtual QString getInfo(QString infokey)  ;
    Q_INVOKABLE virtual void show();
    Q_INVOKABLE virtual void hide() ;
    void videoBackground(bool activate);
    inline bool isModeComposite() {return modeComposite;}


signals:
    void requestReceived(QString reqkey, QString askerApp, QString reqName, QString reqParam);
    void compositeChanged();

private :
    QmlWindow * qmlViewer;
    VideoWidget * backgroundWidget;
    QPoint pDiff; //fonction du decorateur
    bool modeComposite;
    void desactiveModeComposite();
    void activeModeComposite();
    void createBackgroundWidget();

private slots:
    void keyEventPressed(int keyCode);
    void responseSlot(QString reqkey,QString response);
    void synchPos();
    void synchSize();
    void showTop();
    void hideTop();

public slots:
    void focusAppChanged(QWidget * old, QWidget * now);

};

#endif // DBBUSQMLAPP_H
